package util

import (
	"bufio"
	"encoding/json"
	"go-gw-scaffold/dto"
	"os"
)

func ParseGWSConfig(path string) (*dto.GwsConf, error) {
	var conf *dto.GwsConf = &dto.GwsConf{}
	file, error := os.Open(path)
	if error != nil {
		panic(error)
	}
	defer file.Close()
	reader := bufio.NewReader(file)
	decoder := json.NewDecoder(reader)
	if error = decoder.Decode(conf); error != nil {
		return nil, error
	}
	return conf, nil
}
